import { createApp } from "vue";
// import "@/mock/index"; //注意这个mock最好放在使用文件的最上面，否则有的文件请求拦截不到，是个大坑,不过后面我修改了逻辑因该可以随便放置了
import "element-plus/dist/index.css";
import "@/assets/css/index.css";
//引入element-plus所有图标
import * as Elicons from "@element-plus/icons-vue";
import App from "./App.vue";
import echarts from "@/util/echarts"; //echarts按需引入
import { globalPlgun } from "@/util/index";
import { createPinia } from "pinia";
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate';
const pinia = createPinia();
pinia.use(piniaPluginPersistedstate);
//引入写好的路由表并注册到app上
import { router } from "./router/index";
import "./util/routerBefore";
// wow 样式,这是一个动画效果库，不过只支持整体页面滚动哦
import "wow.js/css/libs/animate.css";
//必须写这个帮我们自动更新注册svg图标
import "virtual:svg-icons-register";
//引入封装的svg组件注册全局组件使用
import SvgIcon from "./components/svg.vue";
import AllIcon from "./components/allIcon.vue";
//引入全局包裹容器
import ControlWrap from "./components/ControlWrap/index.vue"
//引入全局自定义指令
import setGlobalDirective from "@/util/globalDirective";
//引入nextId
import { genrateFunction } from "@/util/nextId";
//初始化nextId生成器
genrateFunction();
//创建一个 Vue 应用程序实例
const app = createApp(App);
setGlobalDirective(app);
globalPlgun(app)
//初始化pinia插件并安装到应用程序实例上
// const pinia=createPinia()这种方式会报错，调用use开头的方法就报错没有安装
//全局注册elementplus icon
Object.keys(Elicons).forEach((key) => {
  //如果使用的是ts语法，加上as keyof typeof Elicons可避免报错
  app.component(key, Elicons[key as keyof typeof Elicons]);
});
//全局引入echarts对象挂载Vue应用程序实例上
// app.provide("echarts", echarts);
// app.use(ElementPlus, {
//   locale: zhCn,
// });
app.use(pinia);
app.use(router);
app.component("ControlWrap",ControlWrap)
app.component("SvgIcon", SvgIcon);
app.component("AllIcon", AllIcon);
app.mount("#app");
